function F = cal_objfcn(data, model, bartik)
%% Calculate objective function value (full model)   
    
    % number of suppliers and customers by quintile (10)
    diff1 = (model.mean_indegree_d - data.mean_indegree_d)/mean(data.mean_indegree_d);
    diff2 = (model.mean_outdegree_d - data.mean_outdegree_d)/mean(data.mean_outdegree_d);
    
    % sd of log sales by quintile (5)
    diff3 = (sqrt(model.var_lnsales_d) - data.sd_lnsales_d)/mean(data.sd_lnsales_d);
    
    % share of total network sales by quintile (5)
    diff4 = (model.network_sales_share_d - data.network_sales_share_d)/mean(data.network_sales_share_d);  
        
    % fraction of exporters by quintile (5)
    diff5 = (model.exporter_share_d - data.exporter_share_d)/mean(data.exporter_share_d);
        
    % export intensity of exporters by quintile (5)
    diff6 = (model.export_intensity_d - data.export_intensity_d)/mean(data.export_intensity_d);    
    
    % unwgt. and wgt. average log wage suppliers by quintile (8)
    diff7 = (model.avg_unwgt_lnwageS_d4 - data.avg_unwgt_lnwageS_d4)/mean(data.avg_unwgt_lnwageS_d4);
    diff8 = (model.avg_wgt_lnwageS_d4 - data.avg_wgt_lnwageS_d4)/mean(data.avg_wgt_lnwageS_d4);
        
    % shift-share IV coefficient
    diff9 = (bartik.avg_wage_response - data.bartik_wage_response)/(data.bartik_wage_response-1);
    
    % calculate objective function 
    obj = sum(diff1.^2) + sum(diff2.^2) + sum(diff3.^2) + sum(diff4.^2) ...
        + sum(diff5.^2) + sum(diff6.^2) + sum(diff7.^2) + sum(diff8.^2) + sum(diff9.^2)*10; 
             
    % Return
    F = obj;

end